package com.ruoyi.project.inspection.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.inspection.domain.ViVehicleTypeImg;
import com.ruoyi.project.inspection.service.IViVehicleTypeImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车型图片说明Controller
 *
 * @author ruoyi
 * @date 2020-07-17
 */
@RestController
@RequestMapping("/inspection/img")
public class ViVehicleTypeImgController extends BaseController {
    @Autowired
    private IViVehicleTypeImgService viVehicleTypeImgService;

    /**
     * 查询车型图片说明列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:img:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViVehicleTypeImg viVehicleTypeImg) {
        startPage();
        List<ViVehicleTypeImg> list = viVehicleTypeImgService.selectViVehicleTypeImgList(viVehicleTypeImg);
        return getDataTable(list);
    }

    /**
     * 导出车型图片说明列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:img:export')")
    @Log(title = "车型图片说明", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ViVehicleTypeImg viVehicleTypeImg) {
        List<ViVehicleTypeImg> list = viVehicleTypeImgService.selectViVehicleTypeImgList(viVehicleTypeImg);
        ExcelUtil<ViVehicleTypeImg> util = new ExcelUtil<ViVehicleTypeImg>(ViVehicleTypeImg.class);
        return util.exportExcel(list, "img");
    }

    /**
     * 获取车型图片说明详细信息
     */
    @PreAuthorize("@ss.hasPermi('inspection:img:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(viVehicleTypeImgService.selectViVehicleTypeImgById(id));
    }

    /**
     * 新增车型图片说明
     */
    @PreAuthorize("@ss.hasPermi('inspection:img:add')")
    @Log(title = "车型图片说明", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViVehicleTypeImg viVehicleTypeImg) {
        return toAjax(viVehicleTypeImgService.insertViVehicleTypeImg(viVehicleTypeImg));
    }

    /**
     * 修改车型图片说明
     */
    @PreAuthorize("@ss.hasPermi('inspection:img:edit')")
    @Log(title = "车型图片说明", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViVehicleTypeImg viVehicleTypeImg) {
        return toAjax(viVehicleTypeImgService.updateViVehicleTypeImg(viVehicleTypeImg));
    }

    /**
     * 删除车型图片说明
     */
    @PreAuthorize("@ss.hasPermi('inspection:img:remove')")
    @Log(title = "车型图片说明", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(viVehicleTypeImgService.deleteViVehicleTypeImgByIds(ids));
    }
}
